/* 
 * File:   tasks.h
 * Author: Administrator
 *
 * Created on 2013?8?23?, ??11:27
 */

#ifndef TASKS_H
#define	TASKS_H

#ifdef	__cplusplus
extern "C" {
#endif




#ifdef	__cplusplus
}
#endif
extern unsigned int hit, miss, falseAlarm, correctRejection, od, in, correctRatio, discrimRate_oneback, lr, lm, lw, lc;

extern unsigned char text[16];
extern unsigned char text1[16];
extern unsigned char text7[16];

extern unsigned char text7_2[16];
extern unsigned char text7_3[16];
extern unsigned char text7_4[16];
extern unsigned char text7_5[16];

extern unsigned char text8[16];
extern unsigned char text8_2[16];
extern unsigned char text9[16];
extern unsigned char text10[16];

struct flagStruct {
    unsigned aca : 1;
    unsigned acb : 1;
    unsigned bca : 1;
    unsigned bcb : 1;
    unsigned ada : 1;
    unsigned adb : 1;
    unsigned bda : 1;
    unsigned bdb : 1;
    unsigned aal : 1;
    unsigned bbl : 1;
    unsigned abl : 1;
    unsigned bal : 1;
    unsigned pun : 1;
    unsigned punable : 1;

    unsigned lick : 1;
    unsigned aa : 1;
    unsigned bb : 1;
    unsigned ab : 1;
    unsigned ba : 1;


};

extern struct flagStruct Flags;
extern int currentMiss;
extern unsigned int flaga;
extern unsigned int flagb;






void SW_deal(void);
void SetupPorts(void);

void Stimulate1(void);
void Stimulate2(void);
void Stimulate3(void);
void Stimulate4(void);
void Stimulate5(void);
void Stimulate6(void);

void AB_BA_Go_AA_BB_Nogo(int thisdelay);
void AB_BA_Go_AA_BB_Nogo_Ran(int thisdelay, int thistrialnum);
void auto_AB_BA_Go_AA_BB_Nogo_5delays_Ran(int D1, int D2, int D3, int D4, int D5, int ITI1, int ITI2, int ITI3, int ITI4, int ITI5);
void AB_BA_Go_AA_BB_Nogo_opto_delay(void);
void cfos_control(int controldelay, int controlITI);

void test_water(void);
void test_odorA(void);
void test_odorB(void);
void test_odorC(void);
void test_odorD(void);
void ProgressS2S4(void);
void ProgressS2S5(void);
void auto_AB_BA_Go_AA_BB_Nogo(int thisdelay);
void auto_AB_BA_Go_AA_BB_Nogo_Ran(int thisdelay, int interti, int thistrialnum, int waterLen);
void auto_Transfer(int thisdelay, int interti, int trialNumperSess, int AftOdorID1, int AftOdorID2);
void nogo(int go_odor, int nogo_odor, float odorLen, float delay, float waterlen,                                                                   \
          int ITI, int odorlaseryes, int delaylaseryes, int waterlaseryes, int ITI1, int ITI2);
void go(int go_odor, int nogo_odor, float odorLen, float delay, float waterlen,                                                                   \
          int ITI, int odorlaseryes, int delaylaseryes, int waterlaseryes, int ITI1, int ITI2);

void go_nogo(int trialInSesion, int go_odor, int nogo_odor, float odorLen, float delay, float waterlen,                                                                   \
             int ITI, int odorlaseryes, int delaylaseryes, int waterlaseryes, int ITI1, int ITI2);

void test_opto2(int presti, int lighton, int lightoff, int NumStep);

void ProgressS3S3(void);
void ProgressS3S4(void);
void ProgressS3S5(void);
void ProgressS4S1(void);
void ProgressS4S2(void);
void ProgressS4S3(void);
void ProgressS4S4(void);
void transdiff_sti(int pulsenum, int pulsedura, int interpulsedura, int trainnum, int intertrainint, int interip);

void auto_AA_BB_Go_AB_BA_Nogo_Ran(int thisdelay, int interti, int thistrialnum);
void ProgressS5S2(void);
void ProgressS5S3(void);
void ProgressS5S4(void);
void ProgressS5S5(void);

void auto_AB_BA_Go_AA_BB_Nogo_Ran_indicator_nostop(int thisdelay, int interti, int thistrialnum);
void Sti2oDNMS_Go_indicator(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward);
void Sti2oDNMS_Nogo_indicator(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward);

void auto_AA_BB_Go_AB_BA_Nogo_Ran_indicator(int thisdelay, int interti, int trialNumperSess, float WaterLen);
void auto_AB_BA_Go_AA_BB_Nogo_5delays_Ran_lesion(int D1, int D2, int D3, int D4, int D5, int ITI1, int ITI2, int ITI3, int ITI4, int ITI5);

void test_opto(int presti, int FreqStim, int DuraStim, int totalStimTime, int trainnum, int intertrainint);

void test_opto3(int Numcycle, int innercycle, int lighton, int lightoff, int innerlighton, int innerlightoff);
void auto_AB_BA_Go_AA_BB_Nogo_Ran_indicator(int thisdelay, int interti, int trialNumperSess, float WaterLen);
void test_lick(void);
void test_BNC(void);
void AB_BA_Go_AA_BB_Nogo_Ran_opto_constant(int option, int thisdelay, int ITI);


void Sti2oDNMS_Go_opto_constant(int option, int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn);
void Sti2oDNMS_Nogo_opto_constant(int option, int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn);

void FourOdor_DNMS(int O1, int O2, int O3, int O4, int thisdelay, int interti, int trialNumperSess);
void DNMS_trial_LED(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward);
void AB_BA_Go_AA_BB_Nogo_Ran_blue_delay_last4s(int thisdelay, int ITI, int thistrialnum, int Freq, int PulseOn);
void Sti2oDNMS_Go_opto_delay_last4s(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int Freq, int PulseOn, int sessionNum);
void Sti2oDNMS_Nogo_opto_delay_last4s(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int Freq, int PulseOn, int sessionNum);
void capacity_limit_odor_ABC(int thistrialnum, int thisdelay);
void ABC_lick_indicator(int FirstOdorIn, float FirOdorLen, int SecondOdorIn, float SecOdorLen, int OdorDelayIn, int ThirdOdorIn, float TirOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward);
void ABC_no_lick_indicator(int FirstOdorIn, float FirOdorLen, int SecondOdorIn, float SecOdorLen, int OdorDelayIn, int ThirdOdorIn, float TirOdorLen, float WaterLIn, int IntervalIn, int prolong);
void Psudotask_blue_delay(int thisdelay, int ITI, int thistrialnum, int Freq, int PulseOn);
void AA_BA_Go(int thisdelay, int ITI);
void AB_BA_Go_AA_BB_Nogo_Ran_opto_phase(int option, int thisdelay, int ITI, int Freq, int PulseOn);
void Sti2oDNMS_Nogo_opto_phase(int option, int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int Freq, int PulseOn, int sessionNum);
void Sti2oDNMS_Go_opto_phase(int option, int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int Freq, int PulseOn, int sessionNum);
void AB_BA_Go(int thisdelay, int ITI, float waterlen, float delay2);
void ODNMS_Go(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, float delay_before_reward);
void ODNMS_Nogo_withTrigger(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward, float TriggerStart, float TriggerEnd);
void ODNMS_Go_withTrigger(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, float delay_before_reward, float TriggerStart, float TriggerEnd);
void auto_AB_BA_Go_AA_BB_Nogo_Ran_new(int thisdelay, int interti, int trialNumperSess, float waterlen, int delay2, int missstop, int sessstop);
void auto_AB_BA_Go_AA_BB_Nogo_Ran_new_new(int thisdelay, int interti, int trialNumperSess, float waterlen, int delay2, int missstop, int sessstop, float odorlen);
void auto_AB_BA_Go_AA_BB_Nogo_Ran_new_withTrigger(int thisdelay, int interti, int trialNumperSess, float waterlen, int delay2, int missstop, int sessstop, float TriggerStart, float TriggerEnd);
void auto_AB_BA_Go_AA_BB_Nogo_Ran_OdorControl(int thisdelay, int interti, int trialNumperSess, float waterlen, int delay2, int missstop, int sessstop, int OdorOne, int OdorTwo);
void auto_AB_BA_Go_AA_BB_Nogo_Ran_indicator_onebacktest(int thisdelay, int interti, int trialNumperSess);
void AB_BA_Go_shortDelay(float thisdelay, int ITI, float waterlen, float delay2);
void auto_AA_BB_Go_AB_BA_Nogo_Ran_new(int thisdelay, int interti, int trialNumperSess, float waterlen, int delay2, int missstop, int sessstop);
void AB_BA_Go_AA_BB_Nogo_Ran_blue_delay(int thisdelay, int ITI, int ontrial, int intertrial, int offtrial, int Freq, int PulseOn);
void AB_BA_Go_AA_BB_Nogo_Ran_odor(int thisdelay, int ITI, int ontrial, int intertrial, int offtrial, int Freq, int PulseOn);
void AB_BA_Go_AA_BB_Nogo_Ran_ITI(int thisdelay, int ITI, int ontrial, int intertrial, int offtrial, int Freq, int PulseOn);
void shaping_main2(int thisdelay, int interti, int trialNumperSess, float delay2, int missstop, int sessstop);

void Sti2oDNMS_Go(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, int WaterLIn, int IntervalIn, int prolong);
void Sti2oDNMS_Nogo(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, int WaterLIn, int IntervalIn, int prolong);

void Stimulate21(void);
void Stimulate22(void);
void Stimulate23(void);
void Stimulate24(void);
void Stimulate25(void);
void Stimulate26(void);
void Stimulate27(void);
void Stimulate28(void);

void Sti2oDNMS_Go_indicator_onebacktest(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward);
void Sti2oDNMS_Nogo_indicator_onebacktest(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward);
void Sti2oDNMS_Go_opto_delay(int sessionNum, int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward, int Freq, int PulseOn, int ontrial, int intertrial, int offtrial);
void Sti2oDNMS_Nogo_opto_delay(int sessionNum, int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward, int Freq, int PulseOn, int ontrial, int intertrial, int offtrial);

void Sti2oDNMS_Go_opto_odor(int sessionNum, int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward, int Freq, int PulseOn, int ontrial, int intertrial, int offtrial);
void Sti2oDNMS_Nogo_opto_odor(int sessionNum, int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward, int Freq, int PulseOn, int ontrial, int intertrial, int offtrial);

void Sti2oDNMS_Go_opto_ITI(int sessionNum, int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward, int Freq, int PulseOn, int ontrial, int intertrial, int offtrial);
void Sti2oDNMS_Nogo_opto_ITI(int sessionNum, int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward, int Freq, int PulseOn, int ontrial, int intertrial, int offtrial);

void shaping_go2(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, int IntervalIn, float delay_before_reward);

void ODNMS_Go_shortDelay(int FirstOdorIn, float FirOdorLen, float OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, float delay_before_reward);

void VaryingDelay(int OdorA, int OdorB, float Delay1, float Delay2, float Delay3, int Times1, int Times2, int Times3, int Sessions, float Waterlen, float Response, float Odorlen);
void VaryingOdor(int OdorA, int OdorB, float Odor1, float Odor2, float Odor3, int Times1, int Times2, int Times3, int Sessions, float Waterlen, float Response, float Delay);

void AA_BB_Go(int thisdelay, int ITI, float waterlen, float delay2);

void Go(int OdorIn, float OdorLen, float WaterLIn, int IntervalIn, int prolong, float delay_before_reward);
void Nogo(int OdorIn, float OdorLen, float WaterLIn, int IntervalIn, int prolong, float delay_before_reward);
void NewBurstStimOut2(int FreqStim, int DuraStim, int totalStimTime) ;
void ODMS(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward) ;
void ODNMS(int FirstOdorIn, float FirOdorLen, int OdorDelayIn, int SecondOdorIn, float SecOdorLen, float WaterLIn, int IntervalIn, int prolong, int delay_before_reward) ;
void rule_switch_MNM(int thisdelay, int interti, int trialNumperSess, float WaterLen, int thresh, int randomtrial_n, int delay_before_reward) ;
void rule_switch_NMN(int thisdelay, int interti, int trialNumperSess, float WaterLen, int thresh, int randomtrial_n, int delay_before_reward) ;
#endif	/* TASKS_H */

